]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspacesDisplay: Connect to 'notify::n-workspaces' early
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 28 Mar 2012 13:25:33 +0000 (15:25 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 1 Jun 2012 15:34:48 +0000 (17:34 +0200)
Currently we only connect to the 'notify::n-workspaces' signal the
first time the overview is shown, which means we will miss any
changes to the workspace layout in the meanwhile.
In particular, the decision of whether the workspace switcher should be
shown is taken before the dynamic workspace handling takes over, and is
thus based entirely on the value of the num-workspaces user preference
rather than the actual number of workspaces.
Just connect the signal in _init() (with the nice side-effect to make it
explicit that the signal handler won't ever be disconnected).

https://bugzilla.gnome.org/show_bug.cgi?id=673198

js/ui/workspacesView.js

index e364509f286cf42cd7c87c2f54b371e91447a516..df3143fefb4f0d51e2c2ad189608a00a7849ac0a 100644 (file)
@@ -529,9 +529,11 @@ const WorkspacesDisplay = new Lang.Class({
             this._updateAlwaysZoom();
         }));
 
+        global.screen.connect('notify::n-workspaces',
+                              Lang.bind(this, this._workspacesChanged));
+
         this._switchWorkspaceNotifyId = 0;
 
-        this._nWorkspacesChangedId = 0;
         this._itemDragBeginId = 0;
         this._itemDragCancelledId = 0;
         this._itemDragEndId = 0;
@@ -570,9 +572,6 @@ const WorkspacesDisplay = new Lang.Class({
             global.screen.connect('restacked',
                                   Lang.bind(this, this._onRestacked));
 
-        if (this._nWorkspacesChangedId == 0)
-            this._nWorkspacesChangedId = global.screen.connect('notify::n-workspaces',
-                                                               Lang.bind(this, this._workspacesChanged));
         if (this._itemDragBeginId == 0)
             this._itemDragBeginId = Main.overview.connect('item-drag-begin',
                                                           Lang.bind(this, this._dragBegin));
@@ -925,19 +924,16 @@ const WorkspacesDisplay = new Lang.Class({
     },
 
     _workspacesChanged: function() {
-        let oldNumWorkspaces = this._workspaces[0].length;
-        let newNumWorkspaces = global.screen.n_workspaces;
-        let active = global.screen.get_active_workspace_index();
-
-        if (oldNumWorkspaces == newNumWorkspaces)
-            return;
-
         this._updateAlwaysZoom();
         this._updateZoom();
 
         if (this._workspacesViews == null)
             return;
 
+        let oldNumWorkspaces = this._workspaces[0].length;
+        let newNumWorkspaces = global.screen.n_workspaces;
+        let active = global.screen.get_active_workspace_index();
+
         let lostWorkspaces = [];
         if (newNumWorkspaces > oldNumWorkspaces) {
             let monitors = Main.layoutManager.monitors;